let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hiddenmodalput: true,
    hiddenmodalput2: true,
    commentInputs: '',
    signInputs: '',
    info: {}
  },
  onLoad () {
    app.util.request({
      url: 'entry/wxapp/mine',
      success: (res) => {
        console.log(res)
        this.setData({
          info: res.data.data
        })
      }
    })
  },
  onShareAppMessage: function () {
    return {
      title: `${this.data.info.nickname}邀你吐槽他`,
      path: `booleans_zhijiao/index/index?id=${app.globalData.i_id}`,
      imageUrl: "../../images/sample.jpg"
    }
  },
  messageInput () {
    this.setData({
      hiddenmodalput: false
    });
  },
  signInput () {
    this.setData({
      hiddenmodalput2: false
    })
  },
  cancel: function(){
    this.setData({
      hiddenmodalput: true,
      hiddenmodalput2: true
    });
  },
  // 提交
  confirm: function(){
    let that = this
    app.util.request({
      url: 'entry/wxapp/suggestion',
      method: 'POST',
      data: {
        content: that.data.commentInputs
      },
      success: (res) => {
        console.log(res)
        wx.showToast({
          title: res.data.message,
          icon: 'none'
        })
      },
      fail: (res) => {
        console.log(res)
        wx.showToast({
          title: res.data.message,
          icon: 'none'
        })
      }
    })

    this.setData({
      hiddenmodalput: true
    })
  },
  confirm2 () {
    let that = this
    app.util.request({
      url: 'entry/wxapp/personalitysign',
      method: 'POST',
      data: {
        content: that.data.signInputs
      },
      success: (res) => {
        console.log(res)
        wx.showToast({
          title: res.data.message,
          icon: 'none'
        })
      },
      fail: (res) => {
        console.log(res)
        wx.showToast({
          title: res.data.message,
          icon: 'none'
        })
      }
    })

    that.setData({
      hiddenmodalput2: true,
      [`info.personality_sign`]: that.data.signInputs
    })
  },
  commentInputs: function (e) {
    // 获取输入框的内容
    console.log(e)
    var value = e.detail.value
    this.setData({
      commentInputs: e.detail.value
    });
  },
  signInputs (e) {
    var value = e.detail.value
    this.setData({
      signInputs: e.detail.value
    });
  }
})
